package com.recruitment.auth.config;

import com.recruitment.auth.mq.UserMessageProducer;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * RabbitMQ配置类
 */
@Configuration
public class RabbitMQConfig {
    
    /**
     * 用户注册队列
     */
    @Bean
    public Queue userRegisterQueue() {
        return new Queue(UserMessageProducer.USER_REGISTER_QUEUE, true);
    }
    
    /**
     * 用户注册交换机
     */
    @Bean
    public DirectExchange userRegisterExchange() {
        return new DirectExchange(UserMessageProducer.USER_REGISTER_EXCHANGE);
    }
    
    /**
     * 用户注册队列绑定
     */
    @Bean
    public Binding userRegisterBinding() {
        return BindingBuilder.bind(userRegisterQueue())
                .to(userRegisterExchange())
                .with(UserMessageProducer.USER_REGISTER_ROUTING_KEY);
    }
    
    /**
     * 用户登录队列
     */
    @Bean
    public Queue userLoginQueue() {
        return new Queue(UserMessageProducer.USER_LOGIN_QUEUE, true);
    }
    
    /**
     * 用户登录交换机
     */
    @Bean
    public DirectExchange userLoginExchange() {
        return new DirectExchange(UserMessageProducer.USER_LOGIN_EXCHANGE);
    }
    
    /**
     * 用户登录队列绑定
     */
    @Bean
    public Binding userLoginBinding() {
        return BindingBuilder.bind(userLoginQueue())
                .to(userLoginExchange())
                .with(UserMessageProducer.USER_LOGIN_ROUTING_KEY);
    }
} 